<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            文章类型添加
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">

        <link rel="stylesheet" href="/static/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>资讯列表</cite></a>
              <a><cite>添加资讯</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

              <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" action="">

                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">
                                <span class='x-red'>*</span>资讯标题
                            </label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入内容" class="layui-textarea" name="info"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="button" class="layui-btn" lay-submit="" lay-filter="*" value="保存">
                        </div>
                    </form>
                    <div style="height:100px;"></div>
                </div>

              </div>
            </div> 
        </div>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/static/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['element','layer','form'], function(){
                $ = layui.jquery;//jquery
              lement = layui.element();//面包导航
              layer = layui.layer;//弹出层
              form = layui.form();

              
             //监听提交
              form.on('submit(*)', function(data){
                var info = $("textarea[name='info']").val();
                if(info == ""){
                    layer.msg("资讯标题不能为空！",{icon:5,time:2000});return false;
                }
                var date = data.field.info;

                $.ajax({
                    url:"{:url('zixunliebiaoInsert')}",
                    data:{title:date},
                    type:'POST',
                    success:function (res) {
                        if (res.code == 100){
                            layer.msg(res.msg, {icon: 6,time:2000},function () {
                                window.parent.location.reload();
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                            return false;
                        }else{
                            layer.msg(res.msg, {icon: 7,time:2000});return false;
                        }
                    }
                })

              });

            })
        </script>
            
    </body>
</html>